<div class="tpl-content-wrapper">
    <div class="row-content am-cf">
        <div class="row">
            <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                <div class="widget am-cf">
                    <div class="widget-head am-cf">
                        <div class="widget-title  am-cf">{$title}</div>
                    </div>
                    <form id="m_form" action="{:U('delete')}">
                    <div class="widget-body  am-fr">
                        <div class="am-u-sm-12 am-u-md-6 am-u-lg-6">
                            <div class="am-form-group">
                                <div class="am-btn-toolbar">
                                    <div class="am-btn-group am-btn-group-xs">
                                        <button type="submit" class="am-btn am-btn-default am-btn-danger" onclick="return confirm('确定要删除选中的数据吗')"><span class="am-icon-trash-o"></span> 批量删除</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="am-u-sm-12">
                            <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black " >
                                <thead>
                                    <tr>
                                        <th><input type="checkbox" id="del_check_all"></th>
                                        <th style="text-align: center">宝贝</th>
                                        <th>图片</th>
                                        <th>单价</th>
                                        <th>购买数量</th>
                                        <th>生成订单时间</th>
                                        <th>修改订单时间</th>
                                    </tr>
                                </thead>
                                <style>
                                    .bg_black{
                                        background-color: #000 !important;
                                    }
                                </style>
                                <tbody id="c_list">
                                    <volist name="data" id="vo" >
                                        <php>$sum = 0;foreach($vo as $fv){ $sum += $fv['shop_price'] * $fv['num']; }</php>
                                        <tr>
                                            <td class="bg_black"><input type="checkbox" class="del_check" name="id[]" value="{$vo[0].order_id}"></td>
                                            <td class="bg_black order_id"  style="width: 200px">订单号：<span>{$vo[0].order_id}</span></td>
                                            <td class="bg_black">买家：{$vo[0].buyer}</td>
                                            <td class="bg_black">实付款：¥{:keepTwo($sum)}</td>
                                            <td class="bg_black">付款方式：<eq name="vo[0].pay_type" value="1">支付宝<else/>货到付款</eq></td>
                                            <td class="bg_black ">交易状态:<span class="order_status">
                                                <if condition="($vo[0]['status'] eq 1) OR ($vo[0]['status'] eq 2) ">待付款
                                                    <elseif condition="$vo[0]['status'] eq 3"/>待发货
                                                    <elseif condition="$vo[0]['status'] eq 4"/>待收货
                                                    <elseif condition="$vo[0]['status'] eq 5"/>交易成功
                                                </if>
                                                </span>
                                            </td>
                                            <td class="bg_black">
                                                <div class="tpl-table-black-operation">
                                                    <a href="{:U('Order/delete',array('id'=>$vo[0]['order_id']))}" class="tpl-table-black-operation-del"
                                                       onclick="return confirm('确定要删除该数据吗')">
                                                        <i class="am-icon-trash"></i> 删除

                                                    </a>
                                                    <a href="javascript:void(0);" class="change_status_btn tpl-table-black-operation-del">
                                                        <i class="am-icon-pencil"></i> 修改交易状态
                                                    </a>
                                                </div>
                                            </td>
                                        </tr>
                                        <volist name="vo" id="voo">
                                            <tr class="gradeC">
                                                <td></td>
                                                <td style="max-width: 300px">{$voo.title} 【尺码:{$voo.attr}】 【颜色:{$voo.color}】</td>
                                                <td><img src="{$voo.img}" width="50" alt=""></td>
                                                <td  style="text-align: center">¥{$voo.shop_price}</td>
                                                <td style="text-align: center">{$voo.num}</td>
                                                <td>{$voo.c_time|date='Y年m月d日 H:i:s',###}</td>
                                                <td class="u_time">{$voo.u_time|date='Y年m月d日 H:i:s',###}</td>
                                                <td>

                                                </td>
                                            </tr>
                                        </volist>
                                    </volist>
                                </tbody>
                            </table>
                        </div>
                        <div class="am-u-lg-12 am-cf" >
                            <div class="am-fr" id="page">
                                {$page}
                            </div>
                        </div>
                    </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<!--页码-->
<script src="__LAYER__/layer.js"></script>

<script>
    $(document).ready(function(){
        $("#del_check_all").click(function(){
//            $(this).attr("c")
            $(".del_check").prop('checked',$(this).prop('checked'));
        });

        $(".del_check").click(function(){
            if(!$(this).prop("checked")){
                $("#del_check_all").prop("checked",false);
            }else{
                if($(".del_check:checked").length == $(".del_check").length){
                    $("#del_check_all").prop("checked",true);
                }
            }
        })
        $(".change_status_btn").click(function(){
            var order_id = $(this).closest("tr").find(".order_id span").text();
            var form_url = "{:U('change_status')}";
            var content = '<form class="change" action = "' + form_url + '" method="post" '  + '><select name="status" class="status_select">'+
                    '<option value="2">待付款</option>'+
                    '<option value="3">待发货</option>'+
                    '<option value="4">待收货</option>'+
                    '<option value="5">交易成功</option>'+
                    '</select><input type="hidden" name="order_id" value="'+order_id +'"></form>';
            $temp = $(this).closest("tr").find(".order_status").text();
            $temp = $.trim($temp);
            var content= content.replace('>'+$temp,'selected'+'>'+$temp);
            var url = "{:U('change_status')}";
            layer.open({
                area: ['300px', '180px']
                ,title: order_id
                ,shade: 0.6 //遮罩透明度
                ,maxmin: true //允许全屏最小化
                ,content: content
                ,btnAlign: 'c',
                yes: function(index, layero){
                     var status = $(".status_select").val();
                    $(".change").submit();
                    layer.close(index); //如果设定了yes回调，需进行手工关闭
                }
            });

        })


    });//ready结束
</script>